package com.landsend;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.archive.crawler.datamodel.CandidateURI;
import org.archive.crawler.postprocessor.FrontierScheduler;

public class LandSendFrontierScheduler extends FrontierScheduler {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
		
	String regEx_shop = "www\\.landsend\\.com/shop/";
	String regEx_product = "www\\.landsend\\.com/products/";
	Pattern pat_shop= Pattern.compile(regEx_shop); 
	Pattern pat_product = Pattern.compile(regEx_product);
	Matcher mat_shop = null;
	Matcher mat_product = null;

	public LandSendFrontierScheduler(String name) {
		super(name);
	}
	
	protected void schedule(CandidateURI caUri) {
		String uri = caUri.toString();
		mat_shop = pat_shop.matcher(uri);
		mat_product = pat_product.matcher(uri);
		if("dns:www.landsend.com".equals(uri)){
		  getController().getFrontier().schedule(caUri);
		}
		else if(mat_shop.find()){
		//System.out.println("@@  "+uri);
		  getController().getFrontier().schedule(caUri);
		}
		else if(mat_product.find()){
//		System.out.println("===="+uri);
		  getController().getFrontier().schedule(caUri);
			}
       
    }
	

}
